package com.yonyou.pmclouds.billview.plugin;

import com.yonyou.pmclouds.basecom.consts.BillTypeConst;
import com.yonyou.pmclouds.basecom.entity.SuperVO;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.util.BeanHelper;
import com.yonyou.pmclouds.basecom.util.CommonFieldConst;
import com.yonyou.pmclouds.basecom.util.StorageFactory;
import com.yonyou.pmclouds.businessobject.util.BusinessObjectConsts;
import com.yonyou.pmclouds.businessobject.util.PrintPreviewObj2Html;
import com.yonyou.pmclouds.outter.enterprise.EnterpriseInfoQuery;
import com.yonyou.pmclouds.outter.user.UserInfoQuery;
import com.yonyou.pmclouds.workstartreport.entity.WorkStartCheckVO;
import com.yonyou.pmclouds.workstartreport.entity.WorkStartVO;
import com.yonyou.pmclouds.workstopreport.entity.WorkStopVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


@Component
public class WorkStopPlugin implements IBillViewCustomPlugin {

    @Autowired
    private EnterpriseInfoQuery enterpriseInfoQuery;
    @Autowired
    private UserInfoQuery userInfoQuery;
    @Autowired
    private StorageFactory storageFactory;
    @Value("${print.perLineNum}")
    private int perLineNum;

    @Override
    public Object[] fillListBuziField(Object[] objects) throws BusinessException {

        /*WorkStopVO[] workStopVOSS=new WorkStopVO[objects.length];
        for (int i = 0; i < objects.length ; i++){
            workStopVOSS[i]=(WorkStopVO)objects[i];
        }*/

        //补充创建者姓名
        userInfoQuery.tranUserInfoField(objects,new String[]{CommonFieldConst.CREATOR},new String[]{CommonFieldConst.CREATOR_NAME});

        return objects;
    }

    @Override
    public Map<String, Object[]> fillDetailBuziField(SuperVO superVO, HttpServletRequest request) throws BusinessException {
        Map<String,Object[]> resultMap = new HashMap<String,Object[]>();
        resultMap.put(BusinessObjectConsts.PM_WORKSTOP, new Object[]{superVO});
        return resultMap;
    }

    @Override
    public String getBillType() {
        return BillTypeConst.WORKSTOP_BILLTYPE;
    }
}
